//
// Description: 5776. 判断矩阵经轮转后是否一致
// Created by Loading on 2021/6/7.
//

#include <bits/stdc++.h>

using namespace std;

//向右旋转转置
void transRight(vector<vector<int>> &mat) {
    vector<vector<int>> res;
    for (int i = 0; i < mat[0].size(); ++i) {
        vector<int> v;
        for (auto &j : mat) {
            v.emplace_back(j[i]);
        }
        reverse(v.begin(), v.end());
        res.emplace_back(v);
    }

    mat = res;
}

bool findRotation(vector<vector<int>> &mat, vector<vector<int>> &target) {
    for (int i = 0; i < 3; ++i) {
        if (mat == target) {
            return true;
        }
        transRight(mat);
    }
    //最后一次转置完成，需要再判断一次
    if (mat == target) {
        return true;
    }

    return false;
}

int main() {
    vector<vector<int>> mat = {{0, 1},
                               {1, 0}};
    vector<vector<int>> target = {{1, 0},
                                  {0, 1}};

    cout << findRotation(mat, target) << endl;
}